<template>
  <div class="box">
    <h3>我是box组件</h3>
    <hr />
    <p>{{ list }}</p>
    <button @click="ajax">全局模式下发起ajax请求</button>
    <br />
    1.控制台安装 npm i axios -S下载包 <br />
  </div>
</template>

<script>
// import request from '@/components/utils/request.js'
import { ajaxApi } from '@/components/api/ajaxApi.js'

export default {
  name: 'Mybox',
  data() {
    return {
      list: []
    }
  },
  methods: {
    async ajax() {
      const { data: res } = await ajaxApi(1, 10)
      console.log(res)
      this.list = res.list
    }
  },
  created() {}
}
</script>

<style scoped>
.box {
  width: 100%;
  height: 400px;
  background: rgb(220, 224, 172);
}
</style>
